#include <iostream>
#include <cmath>

using namespace std;
typedef unsigned long NUM;

bool is_prime (NUM x)
{
	static NUM p[7000] = {3, 5, 7, -1},  n = 3, i = 7;
	if (x == 2 || x == 3)
		return true;
    if (x%2 == 0 || x%3 == 0)
		return false;

	NUM max = NUM(sqrt(x)), t = (i < max ? i : max), j = 1;

	while (t >= p[j] && x%p[j]) j++;
	if (t >= p[j]) return false;

	while (i <= max)
	{
		NUM d = NUM(sqrt(i+=2)), j = 0;
		while(d >= p[j] && i%p[j]) j++;
		if(d < p[j])
		{
            p[n++] = i;
            p[n] = -1;
            if(x % i == 0)
				return false;
		}
	};

	return true;
};

inline int formula (const int n, const int a, const int b)
{
	return n*n + a*n + b;
}

int main()
{
	int result = 0, max_n = 0, max_a, max_b;

	for (int a = -999; a < 1000; a++)
	{
		for (int b = -999; b < 1000; b++)
		{
			int n = 0, value = formula(n, a, b);
			if (value <= 0) continue;

			while (is_prime(value)) value = formula(++n, a, b);
			if (n > max_n)
			{
				max_n = n;
				max_a = a;
				max_b = b;
			}
		}
	}

	cout << max_a*max_b << endl;
	return 0;
}
